# ################################################################ #
# meta.make                                                        #
#                                                                  #
# Common makefile for meta directories                             #
#                                                                  #
# (c) 2003 Wouter Caarls, Delft University of Technology           #
# ################################################################ #

# Variables ###################################################### #

MAKEFILE_DEPS = Makefile $(SHARE)/vars.make $(SHARE)/include.make $(SHARE)/meta.make

# Administration ################################################# #

$(filter-out $(OVERRIDE_TARGETS), all): subdirs.all

$(filter-out $(OVERRIDE_TARGETS), clean): subdirs.clean
	rm -rf core core.[0-9]* *~ $(NAME)-$(MAJOR).$(MINOR).$(REVISION) $(NAME)-$(MAJOR).$(MINOR).$(REVISION).tar.gz $(NAME)-$(MAJOR).$(MINOR).$(REVISION).tar

$(filter-out $(OVERRIDE_TARGETS), install): subdirs.install $(BINARIES) $(HEADERS)
ifdef BINARIES
	install -d $(PREFIX)/bin
	install -pc $(BINARIES) $(PREFIX)/bin
endif
ifdef LIBRARIES
	install -d $(PREFIX)/lib
	install -pc $(LIBRARIES) $(PREFIX)/lib
endif
ifdef HEADERS
	install -d $(PREFIX)/include
	install -pc -m 644 $(HEADERS) $(PREFIX)/include
endif

$(filter-out $(OVERRIDE_TARGETS), uninstall): subdirs.uninstall
ifdef BINARIES
	rm -f $(BINARIES:%=$(PREFIX)/bin/%)
endif
ifdef LIBRARIES
	rm -f $(LIBRARIES:%=$(PREFIX)/lib/%)
endif
ifdef HEADERS
	rm -f $(HEADERS:%=$(PREFIX)/include/%)
endif

# Distribution ################################################### #

$(filter-out $(OVERRIDE_TARGETS), subdist): clean subdirs.subdist meta.subdist;

$(filter-out $(OVERRIDE_TARGETS), meta.subdist): force
	mkdir -p $(DISTDIR)
	cp $(MAKEFILE_DEPS) $(DISTDIR)/$(SHAREDISTDIR)
ifdef HEADERS
	cp --parent $(HEADERS) $(DISTDIR)
endif
ifdef DISTFILES
	cp --parent $(DISTFILES) $(DISTDIR)
endif
ifdef BINARIES
	cp --parent $(BINARIES) $(DISTDIR)
endif
ifdef LIBRARIES
	cp --parent $(LIBRARIES) $(DISTDIR)
endif
	sed -e "s/.*SHARE *=.*/SHARE = $(SEDSHAREDISTDIR)/" Makefile > $(DISTDIR)/Makefile
